Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget annotation: implement field name according to the specification #7775

Merged
merged 1 commit into from
Nov 2, 2016

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Nov 1, 2016

The original code is difficult to read and, more importantly, performs actions that are not described in the specification. It replaces empty names with a backtick and an index, but this behavior is not described in the specification. While the specification is not entirely clear about what should happen in this case, it does specify that the T field is optional and that multiple field dictionaries may have the same fully qualified name, so to achieve this it makes the most sense to ignore missing T fields during construction of the field name. This is the most specification-compliant solution and, judging by opened issue #6623, also the required and expected behavior.

Fixes #6623.
Part of #7613.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for working on this!
I've added a really minor nit, feel free to land with/without that fixed.

expect(data.annotationType).toEqual(AnnotationType.WIDGET);
expect(data.fieldName).toEqual('foo.bar.baz');

firstParent = secondParent = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since these are both local variables, I don't think that you actually need to bother nulling them out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the new commit.

// them should be provided, bad PDF generators may fail to do so.
if (!dict.has('T') && !dict.has('Parent')) {
warn('Unknown field name, falling back to empty field name.');
return '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree that it's better to just ignore these bad PDF files for now (since we don't have any broken examples to test with)!

The original code is difficult to read and, more importantly, performs
actions that are not described in the specification. It replaces empty
names with a backtick and an index, but this behavior is not described
in the specification. While the specification is not entirely clear
about what should happen in this case, it does specify that the `T`
field is optional and that multiple field dictionaries may have the same
fully qualified name, so to achieve this it makes the most sense to
ignore missing `T` fields during construction of the field name. This is
the most specification-compliant solution and, judging by opened issue mozilla#6623, also the required and expected behavior.
@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/c62c382c53f5d3e/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/c62c382c53f5d3e/output.txt

Total script time: 2.77 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/da3f363f87e9b0b/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/4147403e7cbaf46/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/da3f363f87e9b0b/output.txt

Total script time: 25.61 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Nov 2, 2016

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/4147403e7cbaf46/output.txt

Total script time: 37.84 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 9f8d674 into mozilla:master Nov 2, 2016
@timvandermeij timvandermeij deleted the widget-annotation-name branch November 2, 2016 21:43
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…name

Widget annotation: implement field name according to the specification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants